package xyz.xtt.exchange.constants;

import java.util.Arrays;
import java.util.Objects;

import com.google.common.primitives.Ints;

/**
 * @author huqibo
 * 
 *         资产类型枚举
 */
public enum AssetTypeEnum {
	LAND(0, "地皮"), BIZ_CERTIFICATE(1, "经营证");

	private int code;
	private String desc;

	// 构造函数
	AssetTypeEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	// 获取描述
	public String desc() {
		return desc;
	}

	public static boolean checkType(String checkType) {
		return Arrays.asList(AssetTypeEnum.values()).stream().anyMatch(x -> Objects.equals(x.name(), checkType));
	}

	public static AssetTypeEnum convert(String checkType) {
		return Arrays.asList(AssetTypeEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType))
				.findFirst().orElse(null);
	}

	public static AssetTypeEnum queryConvert(Integer checkType) {
		return Arrays.asList(AssetTypeEnum.values()).stream().filter(x -> Objects.equals(x.code(), checkType))
				.findFirst().orElse(null);
	}

}